﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using KPIS.GERP.GBMS.DAL;
using KPIS.GERP.GBMS.MODEL;
using KPIS.GERP.GBMS.DALFactory;
using KPIS.GERP.GBMS.IBLL;

namespace KPIS.GERP.GBMS.BLL
{
    public class OptionTypeBLL : IOptionTypeBLL
    {
        private static readonly IOptionTypeDAL dal = DataAccess.CreateOptionTypeList();
        private OptionTypeInfo optTypeInfo = new OptionTypeInfo();

        public OptionTypeBLL()
        {

        }

        public void Insert(string name, string lbname, int child, int descr, int jobsite)
        {
            int chkError = dal.Insert(new OptionTypeInfo(0, name, lbname, child, descr, jobsite));

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Update(int seq, string name, string lbname, int child, int descr, int jobsite)
        {
            int chkError = dal.Update(new OptionTypeInfo(0, name, lbname, child, descr, jobsite));

            if (chkError == 0)
            {
                // Error
            }
        }

        public void Delete(int seq)
        {
            int chkError = dal.Delete(seq);
        }

        public IList<OptionTypeInfo> Search(int seq)
        {
            return dal.Search(seq);
        }

        public int MappingOptionTypeEnum(OptionType type)
        {
            int inType = 0;

            switch (type)
            {
                case OptionType.Product: inType = 1; break;
                case OptionType.Market: inType = 2; break;
                case OptionType.Fair: inType = 3; break;
            }

            return inType;
        }
    }
}
